﻿// == UserScript==
// @name ISP_title
// @description Fix title of browser window, add count of tickets, in techsupport in BILLmanager
// @author yumaa@ispsystem.com
// @include https://my.ispsystem.com/manager/*
// == /UserScript==

(function() {
if (window.location.hostname != 'my.ispsystem.com') return;

	opera.addEventListener('BeforeEvent.DOMContentLoaded', function(e) {
		if ( ! ujsCheckPage(Array('title')) ) return;
		
		var origTitle = window.parent.document.title.match(/\(?\d*\)?\s?(.*)/);
		origTitle = origTitle[1];
		window.parent.document.title = origTitle;
		
		if ( ! ujsCheckPage(Array('title','tickets')) ) return;
		
		var cntobj = $id('0-foot');
		if ( cntobj ) {
			cnt = cntobj.innerText.match(/\d+/);
			if (0 != cnt)
				window.parent.document.title = '(' + cnt + ') ' + origTitle;
		}

	}, true);
})();
